<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
    	<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="user-form">
					<input id="problemId" name="problemId" t-h:field="{problem.id}"  type="hidden">
					<div class="select-list">
						<ul>
							<li>
								问题：<input type="text" name="title"  t-h:value="{problem.title}"/>
							</li>
							<li>
								回答内容：<input type="text" name="answer"/>
							</li>
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="system:user:export"><i class="fa fa-download"></i>&nbsp;导出</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
	        	<a class="btn btn-primary" onclick="$.operate.add()" shiro:hasPermission="system:user:add">
	                <i class="fa fa-plus"></i> 添加
	            </a>
	            <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:answer:remove">
	                <i class="fa fa-remove"></i> 删除
	            </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('module:answer:edit')}]];
        var removeFlag = [[${@permission.hasPermi('module:answer:remove')}]];
        var prefix = ctx + "module/answer";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/"+$("#problemId").val(),
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "答疑管理",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '编号' ,
		            visible: false
				},
				{
					field : 'problemId', 
					title : '问题id' ,
		            visible: false
				},
				{
					field : 'title', 
					title : '问题' 
				},
				{
					field : 'answer', 
					title : '回答内容' 
				},
				{
					field : 'score', 
					title : '评分' 
				},
				{
					field : 'userId', 
					title : '回答者ID' ,
		            visible: false
				},
				{
					field : 'createBy', 
					title : '回答者' 
				},
				{
					field : 'createTime', 
					title : '回答时间' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>